<template>
	<view>
		<view  style="height: 200rpx;"></view>
		<view class="foot" >
			<view class="page-footer" id="target"  >
				<view class="foot-item" v-for="(item,index) in menuList" :key="index"
					@click="goRouter(item)">
                    <image v-if="index==active" :src="item.selectedIconPath" mode="widthFix"></image>
					<image v-else :src="item.iconPath" mode="widthFix"></image>
					
					<view class="" :style="index==active?'color:#0082DB':''">
								{{item.text}}
					</view>
				</view>
               
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		props: {
			active: {
				type: Number,
				default: 0,
			}
		},
		data(){
			return {
				menuList:[
                   {
                   	"pagePath": "/pages/index/index"
                   	,
                   	"iconPath":  require( "../static/images/footer1.png"),
                   	"selectedIconPath": require ("../static/images/footer1-on.png"),
                   	"text": "首页"
                   },
                   {
                   	"pagePath": "/pages/study/index"
                   	,
                   	"iconPath":require("../static/images/footer2.png") ,
                   	"selectedIconPath": require ("../static/images/footer1-on.png"),
                   	"text": "学习"
                   },
                   
                   {
                   	"pagePath": "/pages/exam/index",
                   	"iconPath":require("../static/images/footer3.png") ,
                   "selectedIconPath": require ("../static/images/footer1-on.png"),				
                   	"text": "考试"
                   },
                   {
                   	"pagePath": "/pages/my/index",
                   	"iconPath":require("../static/images/footer4.png") ,
                   	"selectedIconPath": require ("../static/images/footer1-on.png"),
                   	"text": "我的"
                   }
                ]
			}
		},
		mounted() {
			
		},
		methods:{	
			goRouter(item) {
                console.log(item)
				var pages = getCurrentPages();
				var page = (pages[pages.length - 1]).$page.fullPath;
				if (item.pagePath == page) return
				uni.switchTab({
					url: item.pagePath,
					fail(err) {
						uni.redirectTo({
							url: item.pagePath
						})
					}
				})
			},
            toTarot(){
                uni.navigateTo({
                    url:'/pages/AskQuestion/index'
                })
            }
		}
	}
	
</script>

<style lang="scss" scoped>
	.page-footer {
		position: fixed;
		bottom: 0;
		z-index: 300;
		display: flex;
		align-items: center;
		justify-content: space-around;
		width: 100%;
		height: calc(98rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
		height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
		box-sizing: border-box;
			
		
		box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
		padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
		padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
            background: #fff;
            
            
            height: 100rpx;
            box-shadow: 0px -5px 30px 0px rgba(41, 39, 130, 0.1), inset 0px 1px 0.5px 0px rgba(255, 255, 255, 0.5);
            background-blend-mode: overlay;
            backdrop-filter: blur(80px);
		&.filter{
			filter: blur(2rpx);
		}
		.foot-item {
			display: flex;
			width: max-content;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			position: relative;
            z-index: 99;
			font-size: 24rpx;
			color: #9c9c9c;
			.count-num {
				position: absolute;
				display: flex;
				justify-content: center;
				align-items: center;
				width: 40rpx;
				height: 40rpx;
				top: 0rpx;
				right: -15rpx;
				color: #fff;
				font-size: 20rpx;
				background-color: #FD502F;
				border-radius: 50%;
				padding: 4rpx;
			}
            
		}
		.foot-item image {
			height: 45rpx;
			width: 45rpx;
			text-align: center;
			margin: 0 auto 10rpx;
		}
		.foot-item .txt {
			font-size: 24rpx;
		}
	}
</style>
